package com.mep.auth.controller;

import com.mep.auth.feign.IFeignSysDictApi;
import com.mep.auth.model.SysDict;
import com.mep.auth.service.SysDictService;
import com.mep.common.http.HttpResult;
import com.mep.common.page.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 字典控制器
 * @author lyl
 * @date Jan 13, 2019
 */
@Api(value="006-dict的controller",tags="006-dict的controller")
@RestController
@RequestMapping("dict")
public class SysDictController implements IFeignSysDictApi {

	@Autowired
	private SysDictService sysDictService;

	@Override
	@ApiOperation(value="01.保存dict",notes="问题点:保存dict")
	@ApiOperationSupport(order = 1, author = "lyl")
//	@PostMapping(value="/save")
	public HttpResult save(@RequestBody SysDict record) {
		return HttpResult.ok(sysDictService.save(record));
	}

	@Override
	@ApiOperation(value="02.删除dict",notes="问题点:删除dict")
	@ApiOperationSupport(order = 2, author = "lyl")
//	@PostMapping(value="/delete")
	public HttpResult delete(@RequestBody List<SysDict> records) {
		return HttpResult.ok(sysDictService.delete(records));
	}

	@Override
	@ApiOperation(value="03.dict分页数据",notes="问题点:dict分页数据")
	@ApiOperationSupport(order = 3, author = "lyl")
//	@PostMapping(value="/findPage")
	public HttpResult findPage(@RequestBody PageRequest pageRequest) {
		return HttpResult.ok(sysDictService.findPage(pageRequest));
	}

	@Override
	@ApiOperation(value="04.通过label查询dict",notes="问题点:通过label查询dict")
	@ApiOperationSupport(order = 4, author = "lyl")
//	@PostMapping(value="/findByLable")
	public HttpResult findByLable(@RequestParam String lable) {
		return HttpResult.ok(sysDictService.findByLable(lable));
	}
}
